import Api from '@/common/Api';

export const resourceApi = {
    list: Api.newGet("/sys/resources"),
    detail: Api.newGet("/sys/resources/{id}"),
    save: Api.newPost("/sys/resources"),
    update: Api.newPut("/sys/resources/{id}"),
    del: Api.newDelete("/sys/resources/{id}"),
    changeStatus: Api.newPut("/sys/resources/{id}/{status}")
}

export const roleApi = {
    list: Api.newGet("/sys/roles"),
    save: Api.newPost("/sys/roles"),
    update: Api.newPut("/sys/roles/{id}"),
    del: Api.newDelete("/sys/roles/{id}"),
    // 获取指定角色拥有的资源id
    roleResourceIds: Api.newGet("/sys/roles/{id}/resourceIds"),
    roleResources: Api.newGet("/sys/roles/{id}/resources"),
    saveResources: Api.newPost("/sys/roles/{id}/resources")
}

export const accountApi = {
    list: Api.newGet("/sys/accounts"),
    save: Api.newPost("/sys/accounts"),
    update: Api.newPut("/sys/accounts/{id}"),
    del: Api.newDelete("/sys/accounts/{id}"),
    changeStatus: Api.newPut("/sys/accounts/change-status/{id}/{status}"),
    roleIds: Api.newGet("/sys/accounts/{id}/roleIds"),
    roles: Api.newGet("/sys/accounts/{id}/roles"),
    resources: Api.newGet("/sys/accounts/{id}/resources"),
    saveRoles: Api.newPost("/sys/accounts/roles")
}

export const configApi = {
    list: Api.newGet("/sys/configs"),
    save: Api.newPost("/sys/configs"),
    getValue: Api.newGet("/sys/configs/value"),
}

export const logApi = {
    list: Api.newGet("/syslogs")
}